{% extends 'base.html' %}

{% block title %}我报名的活动 - 本地有约{% endblock %}

{% block content %}
<div class="container py-4">
    <h2 class="mb-4">我报名的活动</h2>

    {% if registrations %}
    <div class="list-group">
        {% for registration in registrations %}
        <div class="list-group-item">
            <div class="row align-items-center">
                <div class="col-md-8">
                    <h5 class="mb-1">{{ registration.event.title }}</h5>
                    <div class="d-flex flex-wrap text-muted small mb-2">
                        <span class="me-3"><i class="fas fa-calendar me-1"></i>{{ registration.event.start_time|date:"Y-m-d H:i" }}</span>
                        <span class="me-3"><i class="fas fa-map-marker-alt me-1"></i>{{ registration.event.location }}</span>
                        <span><i class="fas fa-user me-1"></i>{{ registration.event.organizer.username }}</span>
                    </div>
                    <div>
                        <span class="badge {% if registration.status == 'attended' %}bg-success{% elif registration.status == 'cancelled' %}bg-danger{% else %}bg-warning{% endif %}">
                            {{ registration.get_status_display }}
                        </span>
                        <small class="text-muted ms-2">报名时间: {{ registration.registration_time|date:"Y-m-d H:i" }}</small>
                    </div>
                </div>
                <div class="col-md-4 text-end">
                    <a href="{% url 'event_detail' registration.event.id %}" class="btn btn-outline-primary btn-sm">查看活动</a>
                    {% if registration.status == 'registered' %}
                    <button class="btn btn-outline-danger btn-sm">取消报名</button>
                    {% endif %}
                    {% if registration.status == 'attended' and not registration.event.reviews.filter(user=request.user).exists %}
                    <button class="btn btn-primary btn-sm">写评价</button>
                    {% endif %}
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
    {% else %}
    <div class="text-center py-5">
        <i class="fas fa-calendar-check fa-4x text-muted mb-3"></i>
        <h4 class="text-muted">还没有报名任何活动</h4>
        <p class="text-muted mb-4">去发现有趣的活动，结识新朋友吧！</p>
        <a href="{% url 'event_list' %}" class="btn btn-primary btn-lg">发现活动</a>
    </div>
    {% endif %}
</div>
{% endblock %}